using System.Web.Mvc;
using Microsoft.Practices.Unity;
using Unity.Mvc3;
using ShivamEMR.Model;
using ShivamEMR.Data;
using ShivamEMR.Model.DataInterfaces;
using ShivamEMR.Model.DataInterfaces.UsersDataInterf;
using ShivamEMR.Data.Repository.UserRepo;
using ShivamEMR.Model.DataInterfaces.PersonDataInterf;
using ShivamEMR.Data.Repositories.PersonRepo;
using ShivamEMR.Data.Repositories.UserRepo;
using ShivamEMR.Model.DataInterfaces.CompanyDataInterf;
using ShivamEMR.Data.Repositories.CompanyRepo;
using ShivamEMR.Model.DataInterfaces.UIDataInterf;
using ShivamEMR.Data.Repositories.UIRepo;
using ShivamEMR.Model.DataInterfaces.PatientDataInterf;
using ShivamEMR.Data.Repositories.PatientRepo;
using ShivamEMR.Model.DataInterfaces.CRMDataInterf;
using ShivamEMR.Data.Repositories.CRMRepo;
using ShivamEMR.Model.DataInterfaces.AccountsDataInterf;
using ShivamEMR.Data.Repositories.Accounts;
using ShivamEMR.Model.DataInterfaces.AssetsDataInterf;
using ShivamEMR.Data.Repositories.AssetsRepo;
using ShivamEMR.Model.DataInterfaces.CommonDataInterf;
using ShivamEMR.Data.Repositories.CommonRepo;
using ShivamEMR.Model.DataInterfaces.ContactsDataInterf;
using ShivamEMR.Data.Repositories.ContactsRepo;
using ShivamEMR.Model.DataInterfaces.DoctorDataInterf;
using ShivamEMR.Data.Repositories.DoctorRepo;
using ShivamEMR.Model.DataInterfaces.LocationDataInterf;
using ShivamEMR.Data.Repositories.LocationRepo;
using ShivamEMR.Model.DataInterfaces.MedicalDataInterf;
using ShivamEMR.Data.Repositories.MedicalRepo;
using ShivamEMR.Model.DataInterfaces.PharmacyDataInterf;
using ShivamEMR.Data.Repositories.PharmacyRepo;
using ShivamEMR.Model.DataInterfaces.ServiceDataInterf;
using ShivamEMR.Data.Repositories.ServiceRepo;

namespace ShivamEMR.Web
{
    public static class Bootstrapper  
    {
        public static void Initialise()
        {
            var container = BuildUnityContainer();

            Registry.DependencyLocator =new UnityDependencyLocator(container);

            DependencyResolver.SetResolver(new UnityDependencyResolver(container));
        }

        private static IUnityContainer BuildUnityContainer()
        {
            var container = new UnityContainer();

            // register all your components with the container here
            // e.g. container.RegisterType<ITestService, TestService>();            
        
            container.RegisterType<IContext, Context>();
            container.RegisterType<IRepositoryFactory, RepositoryFactory>();

            #region Accounts
           container.RegisterType <IAccountBalanceRepository,AccountBalanceRepository>();
         container.RegisterType <IAccountGroupRepository,AccountGroupRepository>();
         container.RegisterType <IAccountingRuleRepository,AccountingRuleRepository>();
         container.RegisterType <IAccountNatureRepository,AccountNatureRepository>();
         container.RegisterType <IAccountRepository,AccountRepository>();
         container.RegisterType <IAccountsEntryRepository,AccountsEntryRepository >();
         container.RegisterType <IAccountsPictureRepository,AccountsPictureRepository >();
         container.RegisterType <IAccountsPostingTypeRepository,AccountsPostingTypeRepository>();
         container.RegisterType <IAccountStatusRepository,AccountStatusRepository>();
         container.RegisterType <IAccountsTransactionRepository,AccountsTransactionRepository >();
         container.RegisterType <IAccountsTransactionTypeRepository,AccountsTransactionTypeRepository>();
         container.RegisterType <IAccountsVoucherRepository,AccountsVoucherRepository>();
         container.RegisterType <IAccountsVoucherTypeRepository,AccountsVoucherTypeRepository>();
         container.RegisterType <IAccountTypeRepository,AccountTypeRepository >();
         container.RegisterType <IDepreciationRepository,DepreciationRepository >();
         container.RegisterType <IFinancialYearRepository,FinancialYearRepository >();
         container.RegisterType <IMoneyRepository,MoneyRepository>();
         container.RegisterType <IPaymentRepository,PaymentRepository>();
         container.RegisterType <IPaymentStatusRepository,PaymentStatusRepository>();
         container.RegisterType <IPaymentTypeRepository,PaymentTypeRepository >();
         container.RegisterType <IPaymentVoucherRepository,PaymentVoucherRepository >();
         container.RegisterType <IReceiptVoucherRepository,ReceiptVoucherRepository >();
         container.RegisterType <ISalesVoucherRepository,SalesVoucherRepository>();
         container.RegisterType <ITaxInformationRepository,TaxInformationRepository >();
         container.RegisterType <ITaxRepository,TaxRepository >();
         container.RegisterType <ITaxTypeRepository,TaxTypeRepository >();          
            #endregion

            #region AssetModuleRepositories
             container.RegisterType<IAssetGroupRepository, AssetGroupRepository>();
             container.RegisterType<IAssetPictureRepository, AssetPictureRepository>();
             container.RegisterType<IAssetRepository, AssetRepository>();
             container.RegisterType<IAssetStatusRepository, AssetStatusRepository>(); 
             #endregion  

             #region CommonModuleRepositories
             container.RegisterType<IAlertRepository,AlertRepository >();
             container.RegisterType<IDataDictionaryItemStatusRepository,DataDictionaryItemStatusRepository>();
             container.RegisterType<IDataDictionaryRepository,DataDictionaryRepository>();
             container.RegisterType<IDocumentRepository,DocumentRepository >();
             container.RegisterType<IUnitRepository, UnitRepository>(); 
             #endregion

            #region Company
             container.RegisterType<IBranchRepository, BranchRepository>();
             container.RegisterType<IBranchGroupRepository, BranchGroupRepository>();
             container.RegisterType<ICompanyRepository, CompanyRepository>();
             container.RegisterType<ICompanyGroupRepository, CompanyGroupRepository>();
             container.RegisterType<ICompanyPictureRepository, CompanyPictureRepository>();
             container.RegisterType<IDepartmentRepository, DepartmentRepository>();
             container.RegisterType<IDesignationRepository, DesignationRepository>();
             container.RegisterType<IEmployeeRepository, EmployeeRepository>();
             container.RegisterType<IEmployeeGroupRepository, EmployeeGroupRepository>();
             container.RegisterType<IEmployeeScheduleRepository, EmployeeScheduleRepository>();
             container.RegisterType<IEmployeeStatusRepository, EmployeeStatusRepository>();
             container.RegisterType<IScheduleRepository, ScheduleRepository>();
             container.RegisterType<IScheduleSatatusRepository, ScheduleSatatusRepository>();           
            #endregion

            #region Contacts
             container.RegisterType<IAddressRepository, AddressRepository>();
             container.RegisterType<IAddressTypeRepository, AddressTypeRepository>();
             container.RegisterType<ICityRepository, CityRepository>();
             container.RegisterType<IContactRepository, ContactRepository>();
             container.RegisterType<IContactPictureRepository, ContactPictureRepository>();
             container.RegisterType<IContactTypeRepository, ContactTypeRepository>();
             container.RegisterType<ICountryRepository, CountryRepository>();
             container.RegisterType<ICultureAndRegionRepository, CultureAndRegionRepository>();
             container.RegisterType<INationalityRepository, NationalityRepository>();
             container.RegisterType<ITerritoryRepository, TerritoryRepository>(); 
            #endregion

            #region CRM
             container.RegisterType<IAnswerDetailRepository, AnswerDetailRepository>();
             container.RegisterType<IAppointmentGroupRepository, AppointmentGroupRepository>();
            // container.RegisterType<ShivamEMR.Web.Areas.CRM.Models.IAppointmentGroupRepository, ShivamEMR.Web.Areas.CRM.Models.AppointmentGroupRepository>();
             container.RegisterType<IAppointmentRepository, AppointmentRepository>();
             container.RegisterType<IAppointmentStatusRepository, AppointmentStatusRepository>();
             container.RegisterType<IAssignmentGroupRepository, AssignmentGroupRepository>();
             container.RegisterType<IAssignmentRepository, AssignmentRepository>();
             container.RegisterType<IAssignmentStatusRepository, AssignmentStatusRepository>();
             container.RegisterType<IEventRepository, EventRepository>();
             container.RegisterType<IInteractionGroupRepository, InteractionGroupRepository>();
             container.RegisterType<IInteractionRepository, InteractionRepository>();
             container.RegisterType<IMessageGroupRepository, MessageGroupRepository>();
             container.RegisterType<IMessageRepository, MessageRepository>();
             container.RegisterType<IMessageSatusRepository, MessageSatusRepository>();
             container.RegisterType<IMessageTypeRepository, MessageTypeRepository>();
             container.RegisterType<IQuestionAnswerRepository, QuestionAnswerRepository>();
             container.RegisterType<IQuestionGroupRepository, QuestionGroupRepository>();
             container.RegisterType<IQuestionOptionRepository, QuestionOptionRepository>();
             container.RegisterType<IQuestionRepository, QuestionRepository>();
             container.RegisterType<IQuestionStatusRepository, QuestionStatusRepository>();
             container.RegisterType<IQuestionTypeRepository, QuestionTypeRepository>();
             container.RegisterType<IVenueRepository, VenueRepository>(); 
            #endregion

            #region Doctor
             container.RegisterType<IDoctorRepository, DoctorRepository>();
             container.RegisterType<ISpecialtiesRepository, SpecialtiesRepository>(); 
            #endregion

            #region Inventory

            #endregion

             #region LocationModuleRepositories
             container.RegisterType<ILocationGroupRepository, LocationGroupRepository>();
             container.RegisterType<ILocationPictureRepository, LocationPictureRepository>();
             container.RegisterType<ILocationRepository, LocationRepository>(); 
             #endregion

            #region Medical
             container.RegisterType<IDiseaseCategoryRepository, DiseaseCategoryRepository>();
             container.RegisterType<IDiseaseGroupRepository, DiseaseGroupRepository>();
             container.RegisterType<IDiseaseRepository, DiseaseRepository>();
             container.RegisterType<IRadiologyAttachmentRepository, RadiologyAttachmentRepository>();
             container.RegisterType<IRadiologyGroupRepository, RadiologyGroupRepository>();
             container.RegisterType<IRadiologyItemRepository, RadiologyItemRepository>();
             container.RegisterType<IRadiologyRepository, RadiologyRepository>();
             container.RegisterType<ITestRepository, TestRepository>();
             container.RegisterType<ITestGroupRepository, TestGroupRepository>();
             container.RegisterType<ITestItemRepository, TestItemRepository>();
             container.RegisterType<ITreatmentTypeRepository, TreatmentTypeRepository>(); 
            #endregion

            #region Patient
             container.RegisterType<IAdmissionRepository, AdmissionRepository>();
             container.RegisterType<IAdmissionStatusRepository, AdmissionStatusRepository>();
             container.RegisterType<IAdmissionTypeRepository, AdmissionTypeRepository>();
             container.RegisterType<IConsultationRepository, ConsultationRepository>();
             container.RegisterType<IDiagnosisRepository, DiagnosisRepository>();
             container.RegisterType<IDiagnosisStatusRepository, DiagnosisStatusRepository>();
             container.RegisterType<IDiagnosticItemRepository, DiagnosticItemRepository>();
             container.RegisterType<IInsuranceCategoryRepository, InsuranceCategoryRepository>();
             container.RegisterType<IInsurancePlanRepository, InsurancePlanRepository>();
             container.RegisterType<IInsuranceRepository, InsuranceRepository>();
             container.RegisterType<IInsuranceStatusRepository, InsuranceStatusRepository>();
             container.RegisterType<IMedicationRepository, MedicationRepository>();
             container.RegisterType<IMedicationStatusRepository, MedicationStatusRepository>();
             container.RegisterType<IPatientAllergyGroupRepository, PatientAllergyGroupRepository>();
             container.RegisterType<IPatientAllergyRepository, PatientAllergyRepository>();
             container.RegisterType<IPatientGroupRepository, PatientGroupRepository>();
             container.RegisterType<IPatientInformationRepository, PatientInformationRepository>();
             container.RegisterType<IPatientRadiologyAttachmentRepository, PatientRadiologyAttachmentRepository>();
             container.RegisterType<IPatientRadiologyPictureRepository, PatientRadiologyPictureRepository>();
             container.RegisterType<IPatientRadiologyRepository, PatientRadiologyRepository>();
             container.RegisterType<IPatientRepository, PatientRepository>();
             container.RegisterType<IPatientRepresentativeRepository, PatientRepresentativeRepository>();
             container.RegisterType<IPatientServiceRepository, PatientServiceRepository>();
             container.RegisterType<IPatientTestPictureRepository, PatientTestPictureRepository>();
             container.RegisterType<IPatientTestRepository, PatientTestRepository>();
             container.RegisterType<IPatientTreatmentRepository, PatientTreatmentRepository>();
             container.RegisterType<ITreatmentStatusRepository, TreatmentStatusRepository>();            
            #endregion

            #region Person
            container.RegisterType<ISexRepository  , SexRepository>();
            container.RegisterType<IMaritalStatusRepository , MaritalStatusRepository>();
            container.RegisterType<IPersonRepository , PersonRepository>();
            container.RegisterType<IPersonStatusRepository , PersonStatusRepository>();
            container.RegisterType<IPersonPictureRepository , PersonPictureRepository>();
            container.RegisterType< IPersonAccountRepository , PersonAccountRepository>();
            container.RegisterType<IPersonRoleRepository , PersonRoleRepository>();
            container.RegisterType<IPersonStageRepository, PersonStageRepository>();         
            #endregion

            #region Pharmacy
             container.RegisterType<IDosageRepository , DosageRepository>();
        container.RegisterType<IDrugBrandRepository , DrugBrandRepository>();
        container.RegisterType<IDrugCategoryRepository , DrugCategoryRepository>();
        container.RegisterType<IDrugClassRepository , DrugClassRepository>();
        container.RegisterType<IDrugContraIndicationRepository , DrugContraIndicationRepository>();
        container.RegisterType<IDrugGenericRepository , DrugGenericRepository>();
        container.RegisterType<IDrugGroupRepository , DrugGroupRepository>();
        container.RegisterType<IDrugInteractionRepository , DrugInteractionRepository>();
        container.RegisterType<IDrugItemRepository , DrugItemRepository>();
        container.RegisterType<IDrugPackingRepository , DrugPackingRepository>();
        container.RegisterType<IDrugPictureRepository , DrugPictureRepository>();
        container.RegisterType<IDrugRepository, DrugRepository>();
            #endregion

             #region ServiceModuleRepositories
        container.RegisterType<IEMRServiceGroupRepository , EMRServiceGroupRepository>();
        container.RegisterType<IEMRServicePackageRepository , EMRServicePackageRepository>();
        container.RegisterType<IEMRServicePackageStatusRepository , EMRServicePackageStatusRepository>();
        container.RegisterType<IEMRServicePackageTypeRepository , EMRServicePackageTypeRepository>();
        container.RegisterType<IEMRServiceRepository , EMRServiceRepository>();
        container.RegisterType<IEMRServiceSchemeRepository , EMRServiceSchemeRepository>();
        container.RegisterType<IEMRServiceSchemeTypeRepository , EMRServiceSchemeTypeRepository>();
        container.RegisterType<IEMRServiceTypeRepository , EMRServiceTypeRepository>();
        container.RegisterType<IServiceItemRepository , ServiceItemRepository>();
        container.RegisterType<IServiceItemStatusRepository , ServiceItemStatusRepository>();
        container.RegisterType<IServicePictureRepository , ServicePictureRepository>();
        container.RegisterType<IServicePriceRepository , ServicePriceRepository>(); 
        #endregion
            
            #region UI
            //container.RegisterType<IMenuRepository, MenuRepository>();
            //container.RegisterType<IMenuGroupRepository, MenuGroupRepository>();
            container.RegisterType<IUIStyleRepository, UIStyleRepository>();            
            #endregion
          

            #region Users
            container.RegisterType<IUserRepository, UserRepository>();
            container.RegisterType<IUserRoleRepository, UserRoleRepository>();
            container.RegisterType<IUserRightGroupRepository, UserRightGroupRepository>();
            container.RegisterType<IUserRightRepository, UserRightRepository>();
            container.RegisterType<IUserRightTypeRepository, UserRightTypeRepository>();
            container.RegisterType<IAccessPermissionRepository, AccessPermissionRepository>();
            container.RegisterType<IUserTaskRepository, UserTaskRepository>();
            #endregion
       
           

            container.RegisterControllers();

            return container;
        }



         
    }
}